package main

import "fmt"

type Animal interface {
	Speak() string
}

type Dog struct{}
type Cat struct{}

func (d Dog) Speak() string {
	return "狗叫"
}

func (c Cat) Speak() string {
	return "猫叫"
}

func PrintAny(value interface{}) {
	fmt.Println("value:", value)
}

func main() {
	fmt.Println(Dog{}.Speak())
	fmt.Println(Cat{}.Speak())
	fmt.Println(Rectangle{1, 2}.Area())
	fmt.Println(Circle{1.2}.Area())

	var x interface{} = "hello"
	str, ok := x.(int)
	if ok {
		fmt.Println(str)
	} else {
		fmt.Println("not int")
	}

	PrintAny("字符串")
}
